<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Files</title>
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
            font-family: Arial, sans-serif;
        }
        .container {
            max-width: 800px;
            margin: 20px auto;
        }
        .file-list {
            margin-top: 20px;
        }
        .file-item {
            padding: 10px;
            background-color: #ffffff;
            border: 1px solid #e3e3e3;
            margin-bottom: 5px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .file-item a {
            text-decoration: none;
            color: #007bff;
        }
        .alert {
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>Available Files</h2>
        {% with messages = get_flashed_messages(with_categories=true) %}
          {% if messages %}
            {% for category, message in messages %}
              <div class="alert alert-{{ category }}">{{ message }}</div>
            {% endfor %}
          {% endif %}
        {% endwith %}
        <div class="file-list">
            {% for file in files %}
            <div class="file-item">
                <span>{{ file }}</span>
                <a href="{{ url_for('download_file', filename=file) }}" class="btn btn-primary">Download</a>
            </div>
            {% endfor %}
            {% if not files %}
            <p>No files available in the directory.</p>
            {% endif %}
        </div>
    </div>

    <script src="{{ url_for('static', filename='js/jquery-3.5.1.min.js') }}"></script>
    <script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
</body>
</html>
